import { PayloadUser } from '@libs/common/decorator';
import { IndexInterceptor } from '@libs/common/interceptors';
import { Body, Controller, Post, UseInterceptors } from '@nestjs/common';
import { ApiTags } from '@nestjs/swagger';

import { IndexDto } from '../../../libs/common/src/dto/index/index.dto';
import {
  CheckOrderStatusManual,
  IndexOrderDto,
  RefundOrderDto,
  ShowOrderDto,
} from './dto/order.dto';
import { OrderService } from './order.service';

@ApiTags('订单')
@Controller('market/order')
export class OrderController {
  constructor(private readonly orderService: OrderService) {}

  @Post('index')
  @UseInterceptors(new IndexInterceptor())
  index(@Body() dto: IndexOrderDto) {
    return this.orderService.index(dto);
  }

  @Post('show')
  show(@Body() dto: ShowOrderDto) {
    return this.orderService.show(dto);
  }

  @Post('user')
  @UseInterceptors(new IndexInterceptor())
  user(@Body() dto: IndexDto, @PayloadUser() user: SC.User.SysInfo) {
    return this.orderService.findUser(dto, user?.id);
  }

  @Post('refund')
  refund(@Body() dto: RefundOrderDto, @PayloadUser() user: SC.User.SysInfo) {
    return this.orderService.refund(dto, user);
  }

  @Post('check')
  check(@Body() dto: CheckOrderStatusManual) {
    return this.orderService.checkOrderStatusManual(dto);
  }

  // @Post('create')
  // create(@Body() dto: CreateOrderDto) {
  //   return this.orderService.create(dto);
  // }

  // @Post('update')
  // update(@Body() dto: UpdateOrderDto) {
  //   return this.orderService.update(dto);
  // }

  // @Post('import')
  // import(@Body() dto: ExportOrderDto) {}

  // @Post('export')
  // export(@Body() dto: ImportOrderDto) {}

  // @Post('switch')
  // switch(dto: SwitchOrderDto) {
  //   return this.orderService.switch(dto.id, dto.status);
  // }
}
